﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace BML.Infrastructure.Interface
{
    public interface IOperator
    {
        /// <summary>
        ///     查询全部
        /// </summary>
        /// <typeparam name="TEntity">数据库加载对象</typeparam>
        /// <returns></returns>
        IList<TEntity> ReadAll<TEntity>() where TEntity : class;

        /// <summary>
        ///     条件查询
        /// </summary>
        /// <typeparam name="TEntity">数据库加载对象</typeparam>
        /// <param name="predicate">判定性语句</param>
        /// <returns></returns>
        IList<TEntity> Read<TEntity>(Expression<Func<TEntity, bool>> predicate) where TEntity : class;

        /// <summary>
        ///     条件查询
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="predicate"></param>
        /// <returns></returns>
        TEntity ReadSingle<TEntity>(Expression<Func<TEntity,bool>> predicate )where TEntity:class ;

        /// <summary>
        ///     添加
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="entity"></param>
        void Create<TEntity>(TEntity entity) where TEntity : class;


        /// <summary>
        ///     批量更新
        /// </summary>
        /// <typeparam name="TEntity">操作对象类名</typeparam>
        /// <param name="wherePredicate">查询选择</param>
        /// <param name="predicate">对象</param>
        void Update<TEntity>(Expression<Func<TEntity, bool>> wherePredicate,
            Expression<Func<TEntity, TEntity>> predicate)
            where TEntity : class;


        /// <summary>
        ///     批量删除
        /// </summary>
        /// <typeparam name="TEntity">操作对象类名</typeparam>
        /// <param name="predicate">执行条件</param>
        void Delete<TEntity>(Expression<Func<TEntity, bool>> predicate) where TEntity : class;

        

    }
}
